/**
 * 
 */
package com.jysz.certificate.web.action.validator;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.jysz.certificate.action.AbstractBaseAction;
import com.jysz.certificate.service.CommonService;

/**
 * @author kacarich email:javaengine@outlook.com
 * 
 */
@Controller
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
@Namespace("/validator")
public class ScriptValidatorAction extends AbstractBaseAction {
	private String valProperty;
	private String classType;
	private String value;
	private Long entityId;
	private String valueType;
	@Resource
	private CommonService commonService;
	
	private String valPropertyType;
	
	private String datePropertyTypeFormat = "yyyy-MM";
	
	private String sqlRestriction;
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Action("isUnique")
	public String isUnique() {
		
		this.setJsonMsg("", commonService.isUniqueProperty(this.getClassType(), this.getValProperty(), this.getValPropertyType(), value, entityId, sqlRestriction, valueType), null);
		return JSON_PAGE;
	}

	public String getValProperty() {
		return valProperty;
	}

	public void setValProperty(String valProperty) {
		this.valProperty = valProperty;
	}

	public String getClassType() {
		return classType;
	}

	public void setClassType(String classType) {
		this.classType = classType;
	}


	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public Long getEntityId() {
		return entityId;
	}

	public void setEntityId(Long entityId) {
		this.entityId = entityId;
	}

	public String getValPropertyType() {
		return valPropertyType;
	}

	public void setValPropertyType(String valPropertyType) {
		this.valPropertyType = valPropertyType;
	}

	public String getDatePropertyTypeFormat() {
		return datePropertyTypeFormat;
	}

	public void setDatePropertyTypeFormat(String datePropertyTypeFormat) {
		this.datePropertyTypeFormat = datePropertyTypeFormat;
	}

	public String getSqlRestriction() {
		return sqlRestriction;
	}

	public void setSqlRestriction(String sqlRestriction) {
		this.sqlRestriction = sqlRestriction;
	}

	public String getValueType() {
		return valueType;
	}

	public void setValueType(String valueType) {
		this.valueType = valueType;
	}
	
}
